﻿@model Kooboo.CMS.Sites.Models.Page
@{
    ViewBag.Title = "Edit page".Localize();
    Layout = "~/Views/Shared/Blank.cshtml";
    var publishPermission = ServiceFactory.UserManager.Authorize(Kooboo.CMS.Sites.Models.Site.Current, ViewContext.HttpContext.User.Identity.Name, Kooboo.CMS.Account.Models.Permission.Sites_Page_PublishPermission);
}
@section Panel{
    <ul class="panel">
        <li class="j_DropDown">
            <a>
                @Html.IconImage("save")
                @Html.IconImage("arrow small white-down")
                @("Save".Localize())
            </a>
            <ul class="j_DropDownContent hide">
                @if (Model.Published.Value == false || (Model.Published.Value == true && publishPermission))
                {
                    <li><a data-ajaxform="" id="save_bar">@("Save".Localize())</a></li>
                }
                <li><a data-ajaxform="" href="@Url.Action("Save", "Page", ViewContext.RequestContext.AllRouteValues().Merge("saveAsDraft", "true"))">@("Save as draft".Localize())</a></li>
                @if (Model.Published.Value == false && publishPermission)
                {
                    <li><a data-ajaxform="" href="@Url.Action("Save", "Page", ViewContext.RequestContext.AllRouteValues().Merge("setPublished", "true"))">@("Save & publish".Localize())</a></li>
                }
            </ul>
        </li>
        @if (Model.CacheToDisk)
        {
            <li>
                <a href="@Url.Action("DeleteDiskCachings", ViewContext.RequestContext.AllRouteValues())" data-ajaxform="">
                    @Html.IconImage("delete") @("Delete disk cachings".Localize())
                </a>
            </li>
        }
        @if (ServiceFactory.PageManager.IsStaticPage(Model.Site, Model))
        {
            <li><a href="@FrontUrlHelper.Preview(Url, Kooboo.CMS.Sites.Models.Site.Current, Model, null)" target="_blank">@Html.IconImage("preview") @("Preview".Localize())</a></li>
        }
        @foreach (var group in Kooboo.CMS.Sites.Extension.UI.TopToolbar.ToolbarButtons.GetToolbarButtons(ViewContext.RequestContext))
        {
            @Html.Partial("_ToolbarGroupButtons", group)
        }
        <li><a href="@ViewContext.RequestContext.GetRequestValue("return")">@Html.IconImage("cancel") @("Back".Localize())</a></li>
    </ul>
}
<div class="block common-form">
    <h1 class="title">@ViewBag.Title : <strong>@ViewContext.RequestContext.GetRequestValue("UUID")</strong></h1>
    @using (Html.BeginForm("Save", "Page", ViewContext.RequestContext.AllRouteValues()))
    {
        @Html.Hidden("SiteName", ViewContext.RequestContext.GetRequestValue("SiteName"))
        @Html.Hidden("ParentPage", Model.Parent == null ? "" : Model.Parent.FullName)
        @Html.Hidden("old_Key", Model.FullName)
        <input type="hidden" value="@Model.Name" name="Name" />
        @Html.HiddenFor(m => m.Published)
        @Html.ValidationSummary(true)
        @Html.Partial("_PageTabs", Model, new ViewDataDictionary() { { "IsCreating", false } })
    }
</div>

<script type="text/javascript">
    $(function () {
        $('.tabs').koobooTab();
    });
</script>
